package algorithm.leetcode;

import algorithm.templates.TreeNode;

public class NO101_对称二叉树 {
    static class Solution {
        public boolean isSymmetric(TreeNode root) {
            if (root == null) return true;
            return isMirror(root.left, root.right);
        }

        private boolean isMirror(TreeNode left, TreeNode right) {
            if (left == null || right == null) return left == right;
            if (left.val != right.val) return false;
            return isMirror(left.left, right.right) && isMirror(left.right, right.left);
        }
    }
}
